package com.dys.service.impl;

import com.dys.entity.Course;
import com.dys.mapper.CourseDao;
import com.dys.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: 疾风
 * @ClassName: CourseServiceImpl
 * @Description: 课程服务接口实现类
 * @CreateDate: 2024/12/10
 * @Version: v1.0.0
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseDao courseDao;

    @Override
    public List<Course> listCourses() {
        return courseDao.selectAllCourse();
    }

    @Override
    public int saveCourse(Course course) {
        return courseDao.insertCourse(course);
    }

    @Transactional
    @Override
    public void batchSave(List<Course> courses) {
        courses.forEach(item->{
            // item.setCid(null);
            courseDao.insertCourse(item);
        });
    }
}
